home *** CD-ROM | disk | FTP | other *** search
- /* (C) Copyright 1991 Dave Fritsche (wb8zxu), All Rights Reserved.
- *
- * Redistribution and use in source and binary forms are permitted for
- * non-commercial use, provided that the above copyright notice and this
- * paragraph are duplicated in all such forms. THIS SOFTWARE IS PROVIDED
- * ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
- * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE.
- */
- /*bdoc
- * Function "BOX"
- *
- * Written: Dave Fritsche
- * Date: July, 1987
- *
- * A function to draw a rectangle on the screen using only the high-order
- * ascii characters. Four line-types may be selected to be used for
- * drawing these boxes. Syntax:
- * box(ulx, uly, lrx, lry, type)
- * where ulx and uly define the upper left corner of the box to be drawn
- * (ulx is the column number, uly the line number). Same for the lower
- * right corner of the box. Type one is a wide, solid line type. Type
- * two is dual thin lines, type three is a single thin line, type
- * four is composed of standard ascii characters: '+', '-', and '|', and
- * type five writes spaces (to clear a box frame).
- edoc*/
-
- #include <stdio.h>
-
- #define BIOS
-
- #ifdef BIOS
- extern char attrib;
- #endif
-
- box(ulx, uly, lrx, lry, type)
- int ulx, uly, lrx, lry, type;
- {
- int tlc, trc, blc, brc, ts, bs, ls, rs;
- int n;
- #ifdef BIOS
- int attr;
- #endif
-
- switch (type)
- {
- case 1:
- tlc = ts = trc = 220;
- blc = bs = brc = 223;
- ls = 221;
- rs = 222;
- break;
- case 2:
- tlc = 201;
- ts = bs = 205;
- trc = 187;
- blc = 200;
- brc = 188;
- ls = rs = 186;
- break;
- case 3:
- tlc = 218;
- ts = bs = 196;
- trc = 191;
- blc = 192;
- brc = 217;
- ls = rs = 179;
- break;
- case 5:
- tlc = trc = blc = brc = ts = bs = ls = rs = ' ';
- break;
- case 4:
- default:
- tlc = trc = blc = brc = '+';
- ts = bs = '-';
- ls = rs = '|';
- break;
- }
-
- if (ulx > 80) ulx = 80;
- if (uly > 25) uly = 25;
- if (ulx < 1 ) ulx = 1;
- if (uly < 1 ) uly = 1;
- if (lrx > 80) lrx = 80;
- if (lry > 25) lry = 25;
- if (lrx < 1 ) lrx = 1;
- if (lry < 1 ) lry = 1;
-
- #ifndef BIOS
- printf("%c[%d;%dH%c", 27, uly, ulx, tlc);
- printf("%c[%d;%dH%c", 27, uly, lrx, trc);
- printf("%c[%d;%dH%c", 27, lry, ulx, blc);
- printf("%c[%d;%dH%c", 27, lry, lrx, brc);
- printf("%c[%d;%dH", 27, uly, ulx+1);
- for (n = ulx+1; n < lrx; n++)
- printf("%c", ts);
- printf("%c[%d;%dH", 27, lry, ulx+1);
- for (n = ulx+1; n < lrx; n++)
- printf("%c", bs);
- for (n = uly+1; n < lry; n++)
- {
- printf("%c[%d;%dH%c", 27, n, ulx, ls);
- printf("%c[%d;%dH%c", 27, n, lrx, rs);
- }
- #else
- attr = 7;
- if ((attrib & 0x01) != 0) /* Bold */
- attr |= 0x08;
- if ((attrib & 0x18) != 0) /* Blink */
- attr |= 0x80;
- if ((attrib & 0x20) != 0) /* Reverse video */
- {
- attr &= 0xf8;
- attr |= 0x70;
- }
-
- wrbiosch(uly-1, ulx-1, tlc, 1, attr); /* Top left corner */
- wrbiosch(uly-1, lrx-1, trc, 1, attr); /* Top right corner */
- wrbiosch(lry-1, ulx-1, blc, 1, attr); /* Bottom left corner */
- wrbiosch(lry-1, lrx-1, brc, 1, attr); /* Bottom right corner */
- wrbiosch(uly-1, ulx, ts, lrx-ulx-1, attr); /* Top side */
- wrbiosch(lry-1, ulx, bs, lrx-ulx-1, attr); /* Bottom side */
- for (n = uly; n < lry-1; n++)
- {
- wrbiosch(n, ulx-1, ls, 1, attr); /* Left side */
- wrbiosch(n, lrx-1, rs, 1, attr); /* Right side */
- }
- #endif
- }
-